const {
  override,
  addLessLoader,
  addWebpackAlias,
  addWebpackPlugin,
} = require("customize-cra");
const path = require("path");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
  .BundleAnalyzerPlugin;

module.exports = override(
  addLessLoader({
    lessOptions: {
      javascriptEnabled: true,
    },
  }),
  process.env.REACT_APP_ANALYZE === "true" &&
    addWebpackPlugin(new BundleAnalyzerPlugin()),
  addWebpackAlias({
    "@src": path.resolve(__dirname, "src"),
    "@images": path.resolve(__dirname, "src/images"),
    "@utils": path.resolve(__dirname, "src/utils"),
    "@pages": path.resolve(__dirname, "src/pages"),
  })
);
